﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Collections;

namespace Kokomo.Mirror.CliMetadata
{
	class RowNumberPropertyDescriptor : PropertyDescriptor
	{
		public RowNumberPropertyDescriptor(
			IList list
			)
			: base("#", new Attribute[0])
		{
			this.List = list;
		}

		public IList List { get; private set; }

		public override object GetValue(object component)
		{
			return this.List.IndexOf(component);
		}
		public override Type PropertyType
		{
			get { return typeof(int); }
		}

		public override bool CanResetValue(object component)
		{
			return false;
		}

		public override Type ComponentType
		{
			get { return typeof(IMetadataRow); }
		}

		public override bool IsReadOnly
		{
			get { return true; }
		}

		public override void ResetValue(object component)
		{
			throw new NotSupportedException();
		}

		public override void SetValue(object component, object value)
		{
			throw new NotSupportedException();
		}

		public override bool ShouldSerializeValue(object component)
		{
			return false;
		}

		public override TypeConverter Converter
		{
			get
			{
				return ComboHexConverter.Default;
			}
		}
	}
}
